package main

import (
	"fmt"
)

func main() {
	//1.省略switch后的变量
	switch { //相当于true
	case true:
		fmt.Println("case后的数值是true。。")
	case false:
		fmt.Println("case后的数值是false。。")
	}
	score := 48
	switch {
	case score >= 90 && score <= 100:
		fmt.Println("优秀")
	case score >= 60 && score < 70:
		fmt.Println("及格")
	case score >= 80 && score < 90:
		fmt.Println("良好")
	case score >= 70 && score < 80:
		fmt.Println("中")
	case score >= 0 && score < 60:
		fmt.Println("不及格")
	}
	//2.case后有多个数值
	a := "A"
	switch a {
	case "A", "B","C","D":
		fmt.Println("A-D")
	case "E","F","G":
		fmt.Println("E-G")
	}
	score = 77
	switch score/10 { // 0,1,2,3,4,5,6,7,8,9,10
	case 9, 10:
		fmt.Println("优秀")
	case 8:
		fmt.Println("良好")
	case 7:
		fmt.Println("中")
	case 6:
		fmt.Println("及格")
	case 5,4,3,2,1,0: //default
		fmt.Println("不及格")
	}
	//3.switch也可以多条初始化语句,一般用于初始化局部变量

	switch s1:="go"; s1 {
	case "go":
		fmt.Println("golang..")
	case "java":
		fmt.Println("java")
	case "php":
		fmt.Println("php")
	case "python":
		fmt.Println("ptyhon")
	default:
		fmt.Println("玩去。。")
	}
	/*
	练习1：给定数字，输出正数，负数，零
	练习2：给定月份，输出该月的天数。
	 */

}
